package com.guslegend.config;


import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class ShardingTableConfig {

    private static final List<String> tableSuffixList=new ArrayList<>();

    private static Random random=new Random();

    //配置启动那些库的前缀
    static {
        tableSuffixList.add("0");
        tableSuffixList.add("a");
    }

    /**
     * 获取随机的前缀
     * @return
     */
    public static String getRandomTableSuffix(String code){
        int hashCode=code.hashCode();
        int index=Math.abs(hashCode)%tableSuffixList.size();
        return tableSuffixList.get(index);
    }
}
